#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
ll n, m;
char mp[1100][1100];
void solve()
{
    ll n;
    cin >> n;
    vector<ll> a(n + 1),b;
    b.push_back(0);
    for (ll i = 1; i <= n;i++)
    {
        cin >> a[i];
        if(a[i]!=a[i-1])
            b.push_back(a[i]);
    }
    b.push_back(0);
    ll now = 1,l=1,r=n;
    ll ans = 0;
    now = l + 1;
    for (ll i = 1; i < b.size();i++)
    {
        if(b[i]>b[i-1]&&b[i]>b[i+1])
        {
            //cout << a[i - 1] << ":" << a[i] << ":" << a[i + 1] << endl;
            ans++;
        }
    }
        cout << ans << endl;
}
int main()
{
    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
